//
//  ZXZMyCustomView.m
//  sheyingzu
//
//  Created by tyu on 29.5.24.
//

#import "ZXZMyCustomView.h"



@interface ZXZMyCustomView ()

@property(weak,nonatomic)UIView *ContentV;

@property(weak,nonatomic)UILabel *rightLable;
@property(weak,nonatomic)UIButton *rightBtn;

@property(weak,nonatomic)UIButton *bgBtn;


@end
@implementation ZXZMyCustomView

- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {

//        self.backgroundColor = [UIView ColorWithHexString:@"000000" alpha:0.7];
        
        [self SetupUI];
    }
    return self;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    [self SetupFrame];
}

- (void)SetupUI
{
    UIView *ContentV = [[UIView alloc]init];
    self.ContentV = ContentV;
    [self addSubview:ContentV];
    ContentV.backgroundColor = [UIColor whiteColor];

    
    UIImageView *ImgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Home_gift1"]];
    [ContentV addSubview:ImgV];
    self.ImgV = ImgV;
//
    UILabel *TitleLab = [[UILabel alloc]init];
    [self.ContentV addSubview:TitleLab];
    self.TitleLab = TitleLab;
    TitleLab.font = [UIFont systemFontOfSize:15];
    TitleLab.textColor = [UIColor blackColor];
    TitleLab.text = @"幸运儿";

    
    UILabel *SubLab  = [[UILabel alloc]init];
    [self.ContentV addSubview:SubLab];
    self.SubLab = SubLab;
    SubLab.font = [UIFont systemFontOfSize:12];
    SubLab.textColor = [UIView ColorWithHexString:@"#666666"];
    SubLab.text = @"相机";
    
    
    
    UILabel *rightLable  = [[UILabel alloc]init];
    [self.ContentV addSubview:rightLable];
    self.rightLable = rightLable;
    rightLable.font = [UIFont systemFontOfSize:16];
    rightLable.textColor = [UIView ColorWithHexString:@"#00B5C0"];
    rightLable.text = @"定制中";
    
    
    
    UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.rightBtn = rightBtn;
    [self.ContentV addSubview:rightBtn];
    [rightBtn setTitle:@"删除" forState:UIControlStateNormal];
    [rightBtn setTitleColor:[UIView ColorWithHexString:@"#00B5C0"] forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
    rightBtn.layer.borderColor = [UIView ColorWithHexString:@"#00B5C0"].CGColor;
    rightBtn.layer.borderWidth = 1;
    self.rightBtn.layer.cornerRadius = 10;
    self.rightBtn.layer.masksToBounds = YES;
    

    
    UIButton *bgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.bgBtn = bgBtn;
    [self.ContentV addSubview:bgBtn];
    [bgBtn addTarget:self action:@selector(ImgVClick) forControlEvents:UIControlEventTouchUpInside];
    
}
- (void)SetupFrame
{
    self.ContentV.frame = self.bounds;
    self.ContentV.layer.cornerRadius = 10;
    self.ContentV.layer.masksToBounds = YES;
    
    

    self.ImgV.frame = CGRectMake(10, 10, 100, 100);
    self.TitleLab.frame = CGRectMake(10, CGRectGetMaxY(self.ImgV.frame)+10, 130, 20);
    self.SubLab.frame = CGRectMake(10, CGRectGetMaxY(self.TitleLab.frame)+10, 130, 20);



    

    self.ImgV.frame = CGRectMake(10, 20, 100, 100);
    self.TitleLab.frame = CGRectMake(CGRectGetMaxX(self.ImgV.frame)+10, CGRectGetMinY(self.ImgV.frame)+10, 180, 20);
    self.SubLab.frame = CGRectMake(CGRectGetMaxX(self.ImgV.frame)+10, CGRectGetMaxY(self.ImgV.frame)-10-20, 110, 20);
    
    self.rightLable.frame = CGRectMake(ScreenWidth-100, CGRectGetMinY(self.ImgV.frame), 100, 20);

    self.rightBtn.frame = CGRectMake(ScreenWidth-130, CGRectGetMaxY(self.ImgV.frame)-40, 80, 40);

    self.bgBtn.frame = CGRectMake(0, 0, ScreenWidth-100, 100);

    
    
}


#pragma mark ==== 事件处理


-(void)rightBtnClick
{
    if (self.rightBtnBlock) {
        self.rightBtnBlock(@"");
    }
}

- (void)ImgVClick
{
    if (self.ClcikBlock) {
        self.ClcikBlock(@"");
    }
}


@end
